package com.jinyu.jyly.ui.mine.address;

import android.app.Activity;


import com.jinyu.jyly.base.BasePresenter;
import com.jinyu.jyly.bean.AllInfoBean;
import com.jinyu.jyly.net.DataManager;

import rx.Subscription;
import rx.functions.Action1;

/**
 * 更新收货地址
 */
public class ShipAddressListPresenter extends BasePresenter<ShipAddressListContract.View> implements ShipAddressListContract.Presenter {

    public Activity mActivity;
    public ShipAddressListContract.View mView;

    public ShipAddressListPresenter(Activity activity, ShipAddressListContract.View view) {
        super(activity, view);
        this.mActivity = activity;
        this.mView = view;
    }

    /**
     * 收货地址列表
     */
    @Override
    public void getAddress() {
        Subscription subscribe = DataManager.getInstance().getAddressList()
                .subscribe(new Action1<AllInfoBean>() {
                    @Override
                    public void call(AllInfoBean info) {
                        if (info != null) {
                            mView.onAddressList(info);
                        }
                    }
                }, new Action1<Throwable>() {
                    @Override
                    public void call(Throwable throwable) {
                        handleError(throwable);
                        throwable.printStackTrace();
                        mView.onFailer(throwable);
                    }
                });
        addSubscribe(subscribe);
    }


}
